package main

import (
	"fmt"
	"strings"
)

// 单元测试-切割字符串
func Split(str string, sep string) []string {
	var ret []string
	index := strings.Index(str, sep)
	for index >= 0 {
		ret = append(ret, str[:index])
		str = str[index+1:]
		// str = str[index+len(sep):]
		index = strings.Index(str, sep)
	}
	ret = append(ret, str)
	return ret
}

func main() {
	str := "2012-03-12-22-241-404"
	temp := Split(str, "-")
	fmt.Printf("temp: %v\n", temp)

	str2 := "name:tom jerry:ass"
	temp2 := Split(str2, " ")
	fmt.Printf("temp2: %v\n", temp2)

	str3 := "/wd=key&user=jack&time=2022/06/21"
	temp3 := Split(str3, "&")
	fmt.Printf("temp2: %v\n", temp3)
}
